public class Sort{
  public static void main(String[] args) {
    SolutionSort ss = new SolutionSort();
    int arr[] = {64,25,12,22,11};
    //ss.selectionSort(arr);
    ss.bubbleSort(arr);
    ss.printArr(arr);
  }

}

class SolutionSort{
  static void selectionSort(int[] arr){
    int min,temp;
    for (int i = 0; i<arr.length;i++ ) {
      min = i;
      for (int j = i+1; j < arr.length; j++) {
        if(arr[min] > arr[j]){
          min = j;
        }
      }
      temp = arr[min];
      arr[min] = arr[i];
      arr[i] = temp;
    }
  }
  static void bubbleSort(int[] arr){
    for (int i=arr.length - 1; i>= 0;i-- ) {
      for(int j = arr.length-1;j>arr.length-i-1;j--){
        if(arr[j] < arr[j-1]){
          int temp = arr[j-1];
          arr[j-1] = arr[j];
          arr[j] = temp;
        }
      }
    }
  }
  static void printArr(int []arr){
    int n = arr.length;
    for(int i = 0; i< n;i++){
      System.out.print(arr[i]+" ");
    }
    System.out.println();
  }
}
